package model

import (
	"time"
)

type MapWarning map[int64]*Warning

type Warning struct {
	Id         int64 `xorm:"pk autoincr"`
	ProjectId  int64
	TracingId  int64
	Num        int64
	Data       string
	CreateTime time.Time `xorm:"created"`
}

func NewWarning(projecId, TracingId int64, data string) *Warning {
	w := new(Warning)
	w.ProjectId = projecId
	w.TracingId = TracingId
	w.Data = data
	w.Num = 1

	return w
}

func (mw MapWarning) GetWarningIds() []int64 {
	warningIds := []int64{}
	for _, v := range mw {
		warningIds = append(warningIds, v.Id)
	}

	return warningIds
}

func (mw MapWarning) GetProjectIds() []int64 {
	projectIds := []int64{}
	for _, v := range mw {
		projectIds = append(projectIds, v.ProjectId)
	}

	return projectIds
}

func (mw MapWarning) GetTracingIds() []int64 {
	tracingIds := []int64{}
	for _, v := range mw {
		tracingIds = append(tracingIds, v.TracingId)
	}

	return tracingIds
}
